<?php
class Website {
	
	public $id = '';
	
	public $userId = '';
	
	public $name = '';
	
	public $url = '';
	
	private $_model = '';
	
	
	public function __construct($websiteId = null) {
		$this->_model = new WebsiteObjModel();
		if($websiteId) {
			$websiteData = $this->_model->getWebsiteById($websiteId);
			foreach ($websiteData as $data) {
				$this->id = $data->id;
				$this->userId = $data->id_user;
				$this->name = $data->name;
				$this->url = $data->url;
			}
		}
	}
	
	public function getOwnerId() {
		return $this->userId;
	}
	
	public function getOwner() {
		return new User($this->getOwnerId());
	}
	
	public function save() {
		if(empty($this->id)) {
			$this->_model->save($this);
		}
	}
	
}